﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style x:Key="{x:Type ContextMenu}" TargetType="{x:Type ContextMenu}">
        <Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}"/>
        <Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
        <Setter Property="Background" Value="{DynamicResource WindowBackground}" />
        <Setter Property="Foreground" Value="{DynamicResource ItemText}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource WindowBorderActive}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="0,6,0,6"/>
        <Setter Property="MinWidth" Value="150" />
        <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContextMenu}">
                    <Grid Margin="4">
                        <Border Background="#0C000000" BorderBrush="#0F000000" BorderThickness="1" CornerRadius="2.5" Margin="-1" />
                        <Border Background="#0A000000" BorderBrush="#0C000000" BorderThickness="1" CornerRadius="2.75" Margin="-2" />

                        <Border x:Name="ContextMenuBorder"
                                Background="{DynamicResource PopupBackground}"
                                BorderBrush="{DynamicResource WindowBorderActive}"
                                BorderThickness="1"
                                Margin="0,-1,0,0">
                            <ScrollViewer Name="ContextMenuScrollViewer">
                                <Grid RenderOptions.ClearTypeHint="Enabled">
                                    <Canvas Height="0" Width="0" HorizontalAlignment="Left" VerticalAlignment="Top">
                                        <Rectangle 
                                            Name="OpaqueRect"
                                            Height="{Binding ElementName=ContextMenuBorder,Path=ActualHeight}" 
                                            Width="{Binding ElementName=ContextMenuBorder,Path=ActualWidth}" 
                                            Fill="{Binding ElementName=ContextMenuBorder,Path=Background}" />
                                    </Canvas>
                                    <ItemsPresenter Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                </Grid>
                            </ScrollViewer>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>